Component({
    data: {
        value: '/pages/index/index',
        list: [{
                value: '/pages/index/index',
                label: '首页',
                icon: 'home'
            },
            {
                value: '/pages/food/food',
                label: '食物',
                icon: 'app'
            },
            {
                value: '/pages/sports/sports',
                label: '运动',
                icon: 'chat'
            },
            {
                value: '/pages/user/user',
                label: '我的',
                icon: 'user'
            },
        ],
    },

    methods: {
        onChange(e) {
            this.setData({
                value: e.detail.value,
            });
            wx.switchTab({
                url: e.detail.value,
            });
        },
        /**
         * 调用给tabbar选中值赋值
         */
        init() {
            const page = getCurrentPages().pop();
			this.setData({
				value: `/${page.route}`
			});
		}
    },
});